import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
  token: '',
  isLogin: false
}

const mutations = {
  setToken (state, str) {
    state.token = str
  },
  setLogin (state, boolen) {
    if (boolen === 1) {
      state.isLogin = true
    }
  }
}

const getters = {
  getToken: state => {
    return state.token
  },
  getLogin: state => {
    return state.isLogin
  }
}

const actions = {
  setToken: ({commit}, str) => commit('setToken', str),
  setLogin: ({commit}, boolen) => commit('setLogin', boolen)
}

export default new Vuex.Store({
  state,
  mutations,
  getters,
  actions
})
